一个可以发送色图的QQ机器人

您所在的位置:网站首页 Nodejs resend 一个可以发送色图的QQ机器人

一个可以发送色图的QQ机器人

#一个可以发送色图的QQ机器人 | 来源: 网络整理| 查看: 265

创建一个可以自动发送色图的QQ机器人,指定关键词或者定时发送。

框架 OICQ,QQ(安卓)协议基于Node.js的实现。 API,luolicon 环境安装安装VSCODE

官方下载

安装node

官方下载

创建项目

创建一个文件夹,比如在桌面新建一个setu-boot文件夹打开文件夹,右键->通过vscode打开

安装依赖

在vscode中的终端窗口输入node -v来检查node.js是否正常

需要的安装# 首先安装yarn npm install -g yarn # 安装OICQ yarn add oicq # 安装node-fetch yarn add node-fetch # 安装定时模块 yarn add node-schedule

完成后修改package.json,添加"type": "module"

新建index.js import createClient from 'oicq' const _qq_account = { platform: 5, uin: 你的QQ号, password: '密码', logLevel: "info", //trace,debug,info,warn,error,mark }; const bot = createClient(_qq_account.uin, { platform: _qq_account.platform, log_level: _qq_account.logLevel }) bot .on("system.login.qrcode", function (e) { this.logger.mark("扫码后按Enter完成登录") process.stdin.once("data", () => { this.login() }) }) .login() exports.bot = bot // template plugins require("./plugin-setu") //hello world process.on("unhandledRejection", (reason, promise) => { console.log('Unhandled Rejection at:', promise, 'reason:', reason) }) 新建plugin-setu.jsimport fetch from 'node-fetch'; import segment from 'oicq' import bot from './index' import schedule from 'node-schedule' bot.on("message.group", msg => { // console.log(msg) if (msg.raw_message.indexOf('色图') > -1) { let res = await fetch('https://api.lolicon.app/setu/v2'); let data = await res.json(); let setu = [ segment.image(data.data[0].urls.original) ] msg.reply(setu, true) .then(res => { setTimeout(() => { msg.group.recallMsg(res.message_id) },20000) })//20S后撤回 } } 运行node index.js # 或者使用pm2管理 npm install -g pm2 pm2 start index.js --name setu


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3